package finassist.DAO;

import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.classic.Session;
import finassist.model.User;
import finassist.util.HibernateUtil;

/**
 * AJ Projects
 * LoginUserManagerDAO.java
 * Purpose: Login User Database.
 *
 * @author Karthick Natarajan
 * @version 1.0 9/10/13
 */

public class LoginUserManagerDAO extends HibernateUtil {

	public List<User> getUserDetails(User user) {
		
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		List<User> users = null;
		
		try {
			
			users = (List<User>)session.createSQLQuery("select * from finassistdb.users where user_username= "+ "'"+user.getUsername()+"'").addEntity(User.class).list();
					
		} catch (HibernateException e) {
			e.printStackTrace();
			session.getTransaction().rollback();
		}
		session.getTransaction().commit();
		return users;
	}
	
}
